//
//  DBJIIllnewwCaseUseProfileView.m
//  DBJ
//
//  Created by Captain_czq on 16/11/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJIIllnewwCaseUseProfileView.h"
@implementation DBJIIllnewwCaseUseProfileView

/**
 重写基类方法设置UI界面
 */
-(void)dbjSetupSubviews{
    [super dbjSetupSubviews];
    self.backgroundColor=[UIColor whiteColor];
      /*设置UI界面*/
    //添加UIImgView-用户照片
    UIImage *image = [UIImage imageNamed:@"logo"];
    UIImageView *userImgView=[[UIImageView alloc]initWithImage:image];
    userImgView.contentMode= UIViewContentModeScaleAspectFit;
    userImgView.clipsToBounds = YES;
    //添加到该视图中
    [self addSubview:userImgView];
    [userImgView sizeToFit];
    
    //添加用户信息
    NSArray *btnIconArry=@[@"login_phone-1",@"id",@"sellphone"];
    NSArray *btnTitleArry=@[@"独孤求败",@"身份证号码",@"你的个人资料信息"];
    
    NSMutableArray<UIButton *> *btnM=[NSMutableArray arrayWithCapacity:btnTitleArry.count];
    for(NSInteger i=0;i<btnIconArry.count;i++){
        
        //调用添加按钮的方法
        UIButton *btnUser=[self addUserinfoWithIconStr:btnIconArry[i] title:btnTitleArry[i]];
        //添加到父视图中
        [self addSubview:btnUser];
        //添加到btn可变数组中
        [btnM addObject:btnUser];
    }
    
    /* 设置子视图的约束 */
   
   //设置用户照片视图的约束
    [userImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(120);
        make.left.equalTo(self).offset(45);
        make.top.equalTo(self).offset(20);
    }];
    
    //设置用户信息按钮的约束
    [btnM mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(userImgView.mas_right).offset(-35);
        make.right.equalTo(self).offset(-8);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(45);
    }];
    
    [btnM[0]mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(userImgView);
    }];
    [btnM[1]mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(btnM[0].mas_bottom);
    }];
    [btnM[2]mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(btnM[1].mas_bottom);
    }];
    [btnM[2]mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btnM[1].mas_left).offset(25);
    }];
    
}

/* 添加用户信息button的方法 */
-(UIButton *)addUserinfoWithIconStr:(NSString *)iconStr title:(NSString *)title{
    
    //创建button按钮
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    //设置btn图片
    [btn setImage:[UIImage imageNamed:iconStr] forState:UIControlStateNormal];
    //设置btn文字信息
    [btn setTitle:title forState:UIControlStateNormal];
    //设置btn文字大小
    btn.titleLabel.font=[UIFont systemFontOfSize:12];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //返回btn
    return  btn;
}


@end
